<template>
  <div class="wh-100" ref="monitorHigh">
    <div class="search wh-100">
      <Row :gutter="16" class="all-height ">
        <Col :span="showRight ? 18 : 24" class="all-height">
          <Card class="all-height card-child-height ">
            <Row class="operation code-row-bg" style="display: flex; justify-content: space-between">
              <Col span="22" class="d-flex-between-center w-100 ">
                <Form ref="form" :model="searchForm" :label-width="0" label-position="left" class="marginForm" inline>
                  <FormItem label="" prop="by">
                    <!--                                        <DatePicker-->
                    <!--                                            v-model="searchForm.by"-->
                    <!--                                            type="year"-->
                    <!--                                            format="yyyy"-->
                    <!--                                            :clearable="false"-->
                    <!--                                            placeholder="选择毕业年度"-->
                    <!--                                            style="width: 100%"-->
                    <!--                                            @on-change="jbChange"-->
                    <!--                                        ></DatePicker>-->
                    <Select v-model="searchForm.time" transfer style="min-width: 200px" clearable>
<!--                      <Option value="2024-03-06">2024-03-06</Option>-->
                      <Option v-for="time in selectTimeList" :value="time">{{ time }}</Option>
                    </Select>
                  </FormItem>
                  <FormItem label="" prop="gx" v-if="roles === 'ROLE_PROVINCE'">
                    <Select v-model="searchForm.gx" transfer style="min-width: 200px" filterable>
                      <Option v-for="item in gxList" :value="item.code">{{ item.name }}</Option>
                    </Select>
                  </FormItem>
                  <FormItem label="" prop="status" v-if="roles === 'ROLE_PROVINCE'">
                    <Select @on-change="handleSelectChange" v-model="searchForm.status" style="width: 280px">
                      <Option value="0">就业落实率统计</Option>
                      <Option value="1">就业统计8个落实率</Option>
                      <Option value="9">就业统计8个落实率-学历层次</Option>
                      <Option value="13">灵活就业率</Option>
                      <Option value="14">灵活就业率-学历层次</Option>
                      <Option value="2">各校专业（大类）落实率</Option>
                      <Option value="3">各校专业（中类）落实率</Option>
                      <Option value="4">各校专业（小类）落实率</Option>
                      <Option value="10">各专业（大类）落实率</Option>
                      <Option value="11">各专业（中类）落实率</Option>
                      <Option value="12">各专业（小类）落实率</Option>
                      <Option value="5">总体岗位数据统计</Option>
                      <Option value="6">高职扩招生数据统计</Option>
                      <!--                                            暂时隐藏-->
                      <!--                                            <Option value="7">5所布点高校数据统计</Option>-->
                      <Option value="8">各高校岗位数据统计</Option>
                    </Select>
                  </FormItem>
                  <FormItem label="" prop="status" v-if="roles === 'ROLE_SCHOOL'">
                    <Select @on-change="handleSelectChange" v-model="searchForm.status" style="width: 280px">
                      <Option value="0">就业落实率统计</Option>
                      <Option value="1">就业统计8个落实率</Option>
                      <Option value="13">灵活就业率</Option>
                      <Option value="2">各院系专业（大类）落实率</Option>
                      <Option value="3">各院系专业（中类）落实率</Option>
                      <Option value="4">各院系专业（小类）落实率</Option>
                      <Option value="5">总体岗位数据统计</Option>
                      <Option value="6">高职扩招生数据统计</Option>
                      <!--                                            暂时隐藏-->
                      <!--                                            <Option value="7">5所布点高校数据统计</Option>-->
                      <Option value="8">各院系岗位数据统计</Option>
                    </Select>
                  </FormItem>
                  <FormItem label="" prop="status" v-if="roles === 'ROLE_COLLEGE'">
                    <Select @on-change="handleSelectChange" v-model="searchForm.status" style="width: 280px">
                      <Option value="0">就业落实率统计</Option>
                      <Option value="1">就业统计8个落实率</Option>
                      <Option value="13">灵活就业率</Option>
                      <Option value="10">各专业（大类）落实率</Option>
                      <Option value="11">各专业（中类）落实率</Option>
                      <Option value="12">各专业（小类）落实率</Option>
                      <Option value="5">总体岗位数据统计</Option>
                      <Option value="6">高职扩招生数据统计</Option>
                      <!--                                            暂时隐藏-->
                      <!--                                            <Option value="7">5所布点高校数据统计</Option>-->
                      <Option value="8">各专业岗位数据统计</Option>
                    </Select>
                  </FormItem>
                  <!--                                    <FormItem v-show="type == 7" label="" prop="gx" v-if="roles === 'ROLE_SCHOOL'">-->
                  <!--                                        <Select v-model="searchForm.yx" transfer style="min-width: 200px" filterable clearable>-->
                  <!--                                            <Option v-for="item in xyList" :value="item">{{ item }}</Option>-->
                  <!--                                        </Select>-->
                  <!--                                    </FormItem>-->
                  <!-- <FormItem label="">
                                        <Cascader :data="xlccList" placeholder="请选择专业" :load-data="zyLoadData" :render-format="zyFormat" v-model="searchForm.zyCode1" v-width="200" />
                                    </FormItem> -->
                  <Button @click="handleSearch" type="primary" icon="ios-search">搜索</Button>
                </Form>
                <Button :loading="loading1" class="button_output" type="primary"
                        @click="dropExportAllEMploymentRateOutPut">导出数据
                </Button>

                <!--                              <Button @click="add" type="primary" icon="md-add">添加</Button>-->
                <!--                              <Button @click="delAll" icon="md-trash">批量删除</Button>-->
                <!--                              <Button @click="getDataList" icon="md-refresh">刷新</Button>-->
              </Col>
              <!--                            <Col span="2">-->
              <!--                                &lt;!&ndash;                            <Button type="primary" @click="exportData()"><Icon type="ios-download-outline"></Icon>Excel下载</Button>&ndash;&gt;-->
              <!--                            </Col>-->
            </Row>
            <!--                      <Row v-show="openTip">-->
            <!--                          <Alert show-icon>-->
            <!--                              已选择-->
            <!--                              <span class="select-count">{{ selectList.length }}</span> 项-->
            <!--                              <a class="select-clear" @click="clearSelectAll">清空</a>-->
            <!--                              <a class="select-clear" style="cursor: pointer" @click="getDataList">刷新</a>-->
            <!--                          </Alert>-->
            <!--                      </Row>-->
            <div class="class01">
              <!--各高校落实率 本校落实率                            -->

              <div v-show="type == 0"  class="wh-100">
                <TableV2
                    id="table1"
                    class="wh-100"
                    show-summary
                    :summary-method="handleSum"
                    :loading="loading"
                    border
                    :columns="columns"
                    :data="data"
                    ref="table1"
                    :max-height="rheight.value-55"
                ></TableV2>
              </div>
              <div v-if="type == 7" class="wh-100">
                <!--                                去掉tab标签-->
                <!--                                <Tabs type="card" v-model="searchForm.xlcc" @on-click="changeTab">-->
                <!--                                    <TabPane v-for="item in xlccList" :label="item.title" :name="item.value"></TabPane>-->
                <!--                                </Tabs>-->
                <TableV2
                    id="table2"
                    class="wh-100"
                    width="100%"
                    show-summary
                    :loading="loading"
                    :summary-method="handleSum2"
                    border
                    :columns="columns"
                    :data="data"
                    ref="table2"
                    :max-height="rheight.value-55"
                >
                </TableV2>
              </div>
              <div v-show="type == 1" class="wh-100 ">
                <!--                                <Tabs type="card" v-model="searchForm.xlcc" @on-click="changeTab">-->
                <!--                                    <TabPane v-for="item in xlccList" :label="item.title" :name="item.value"></TabPane>-->
                <!--                                </Tabs>-->
                <TableV2
                    id="table3"
                    class="wh-100 "
                    show-summary
                    :loading="loading"
                    :summary-method="handleSum3"
                    border
                    :columns="columns3"
                    :data="data"
                    ref="table3"
                    :max-height="rheight.value-55"
                >
                  <template slot-scope="{ row }" slot="majorName">
                    <div v-if="searchForm.status === '2' && row.dl_description!=='小计' ">
                      {{ '(' + row.dl_code + ')' + row.dl_description }}
                    </div>
                    <div v-else-if="searchForm.status === '3' && row.zl_description!=='小计' ">
                      {{ '(' + row.zl_code + ')' + row.zl_description }}
                    </div>
                    <div v-else-if="searchForm.status === '4' && row.xl_description!=='小计' ">
                      {{ '(' + row.xl_code + ')' + row.xl_description }}
                    </div>
                    <div v-else>
                      小计
                    </div>
                  </template>
                </TableV2>
              </div>
              <div v-show="type == 8" class="wh-100">
                <!--                                <Tabs type="card" v-model="searchForm.xlcc" @on-click="changeTab">-->
                <!--                                    <TabPane v-for="item in xlccList" :label="item.title" :name="item.value"></TabPane>-->
                <!--                                </Tabs>-->
                <TableV2
                    class="wh-100"
                    id="table4"
                    width="100%"
                    show-summary
                    :loading="loading"
                    :summary-method="handleSum4"
                    border
                    :columns="columns4"
                    :data="data"
                    ref="table4"
                    :max-height="rheight.value-55"
                >
                  <template slot-scope="{ row }" slot="majorName">
                    <div v-if="searchForm.status === '10' ">
                      {{ '(' + row.dl_code + ')' + row.dl_description }}
                    </div>
                    <div v-if="searchForm.status === '11'">
                      {{ '(' + row.zl_code + ')' + row.zl_description }}
                    </div>
                    <div v-if="searchForm.status === '12'">
                      {{ '(' + row.xl_code + ')' + row.xl_description }}
                    </div>
                  </template>
                </TableV2>
              </div>
              <!-- <Table v-if="type == 2" width="100%" :columns="columnsls3" :data="bysJyqxPostDataStatistics" border max-height="300"></Table> -->
              <div v-show="type == 3" class="table-wrap-self" loading="true">
                <table id="table5" style="width: 100%;" v-loading="loading">
                  <thead style="background-color: #f8f8f9">
                  <tr>
                    <th class="table-wrap-item" scope="row" rowspan="2" colspan="3">岗位类型统计</th>
                    <th class="table-wrap-item" scope="row" colspan="3">专科</th>
                    <th class="table-wrap-item" scope="row" colspan="3">本科</th>
                    <th class="table-wrap-item" scope="row" colspan="3">研究生</th>
                    <th class="table-wrap-item" scope="row" colspan="3">硕士研究生</th>
                    <th class="table-wrap-item" scope="row" colspan="3">博士研究生</th>
                    <th class="table-wrap-item" scope="row" colspan="3">小计</th>
                  </tr>
                  <tr>
                    <th class="table-wrap-item" scope="row">毕业生数量</th>
                    <th class="table-wrap-item" scope="row">已落实</th>
                    <th class="table-wrap-item" scope="row">占比</th>
                    <th class="table-wrap-item" scope="row">毕业生数量</th>
                    <th class="table-wrap-item" scope="row">已落实</th>
                    <th class="table-wrap-item" scope="row">占比</th>
                    <th class="table-wrap-item" scope="row">毕业生数量</th>
                    <th class="table-wrap-item" scope="row">已落实</th>
                    <th class="table-wrap-item" scope="row">占比</th>
                    <th class="table-wrap-item" scope="row">毕业生数量</th>
                    <th class="table-wrap-item" scope="row">已落实</th>
                    <th class="table-wrap-item" scope="row">占比</th>
                    <th class="table-wrap-item" scope="row">毕业生数量</th>
                    <th class="table-wrap-item" scope="row">已落实</th>
                    <th class="table-wrap-item" scope="row">占比</th>
                    <th class="table-wrap-item" scope="row">毕业生数量</th>
                    <th class="table-wrap-item" scope="row">已落实</th>
                    <th class="table-wrap-item" scope="row">占比</th>
                  </tr>
                  </thead>
                  <tbody>
                  <tr>
                    <td class="table-wrap-item" colspan="3">已落实去向合计</td>
                    <td class="table-wrap-item">{{ realizedTotal.zknumberUn }}</td>
                    <td class="table-wrap-item">{{ realizedTotal.zknumber }}</td>
                    <td class="table-wrap-item">{{ realizedTotal.zknumberpn }}</td>
                    <td class="table-wrap-item">{{ realizedTotal.bknumberUn }}</td>
                    <td class="table-wrap-item">{{ realizedTotal.bknumber }}</td>
                    <td class="table-wrap-item">{{ realizedTotal.bknumberpn }}</td>
                    <td class="table-wrap-item">{{ realizedTotal.yjsnumberUn }}</td>
                    <td class="table-wrap-item">{{ realizedTotal.yjsnumber }}</td>
                    <td class="table-wrap-item">{{ realizedTotal.yjsnumberpn }}</td>
                    <td class="table-wrap-item">{{ realizedTotal.yjnumberUn }}</td>
                    <td class="table-wrap-item">{{ realizedTotal.yjnumber }}</td>
                    <td class="table-wrap-item">{{ realizedTotal.yjnumberpn }}</td>
                    <td class="table-wrap-item">{{ realizedTotal.bsnumberUn }}</td>
                    <td class="table-wrap-item">{{ realizedTotal.bsnumber }}</td>
                    <td class="table-wrap-item">{{ realizedTotal.bsnumberpn }}</td>
                    <td class="table-wrap-item">{{ realizedTotal.alnumberUn }}</td>
                    <td class="table-wrap-item">{{ realizedTotal.alnumber }}</td>
                    <td class="table-wrap-item">{{ realizedTotal.alnumberpn }}</td>
                  </tr>
                  <tr v-for="item in bysJyqxPostDataStatistics">
                    <td class="table-wrap-item" v-if="item.topLine != 0" :colspan="item.top" :rowspan="item.topLine">
                      {{ item.topName }}
                    </td>
                    <td class="table-wrap-item" v-if="item.middLine != 0 && item.midd != 0" :colspan="item.midd"
                        :rowspan="item.middLine">{{ item.middName }}
                    </td>
                    <td class="table-wrap-item" v-if="item.end != 0" :colspan="item.end" rowspan="1">{{
                        item.endName
                      }}
                    </td>
                    <td class="table-wrap-item">{{ item.zknumberUn || '0' }}</td>
                    <td class="table-wrap-item">{{ item.zknumber || '0' }}</td>
                    <td class="table-wrap-item">{{ item.zknumberpn || '0.0%' }}</td>
                    <td class="table-wrap-item">{{ item.bknumberUn || '0' }}</td>
                    <td class="table-wrap-item">{{ item.bknumber || '0' }}</td>
                    <td class="table-wrap-item">{{ item.bknumberpn || '0.0%' }}</td>
                    <td class="table-wrap-item">
                      {{ calculateSum(item.yjnumberUn, item.bsnumberUn) || '0' }}
                    </td>
                    <td class="table-wrap-item">
                      {{ calculateSum(item.yjnumber + item.bsnumber) || '0' }}
                    </td>
                    <td class="table-wrap-item">{{ calculateSumpn(item) || '' }}</td>
                    <td class="table-wrap-item">{{ item.yjnumberUn || '0' }}</td>
                    <td class="table-wrap-item">{{ item.yjnumber || '0' }}</td>
                    <td class="table-wrap-item">{{ item.yjnumberpn || '0.0%' }}</td>
                    <td class="table-wrap-item">{{ item.bsnumberUn || '0' }}</td>
                    <td class="table-wrap-item">{{ item.bsnumber || '0' }}</td>
                    <td class="table-wrap-item">{{ item.bsnumberpn || '0.0%' }}</td>
                    <td class="table-wrap-item">{{ item.alnumberUn || '0' }}</td>
                    <td class="table-wrap-item">{{ item.alnumber || '0' }}</td>
                    <td class="table-wrap-item">{{ item.alnumberpn || '0.0%' }}</td>
                  </tr>
                  </tbody>
                </table>
              </div>
              <div v-show="type == 4" class="wh-100">
                <TableV2
                    id="table6"
                    class="wh-100"
                    show-summary
                    :loading="loading"
                    :summary-method="handleSum5"
                    border
                    :columns="columnsls4"
                    :data="tableData"
                    ref="table6"
                    :max-height="rheight.value-55"
                >
                  <template slot-scope="{ row }" slot="chazhi">
                    <strong>{{ row.czjyl || '-' }}</strong>
                  </template>
                  <template slot-scope="{ row }" slot="chazhiLast">
                    <strong>-</strong>
                  </template>
                  <template slot-scope="{ row }" slot="jyl">
                    {{ row.jyl + '%' }}
                  </template>
                </TableV2>
              </div>
              <div v-show="type == 5" class="wh-100">
                <Table id="table7" :loading="loading" show-summary class="wh-100" :columns="columnsls5"
                       :data="tableData" border :max-height="rheight.value-55">
                  <template slot-scope="{ row }" slot="sumN">
                    <strong>{{ ((row.allby * 100) / (row.allpersonnumber || 1)).toFixed(2) }}%({{
                        row.allby
                      }}/{{ row.allpersonnumber }})</strong>
                  </template>
                  <template slot-scope="{ row }" slot="bs">
                    <strong>{{ ((row.bs * 100) / (row.bsall || 1)).toFixed(2) }}%({{ row.bs }}/{{ row.bsall }})</strong>
                  </template>
                  <template slot-scope="{ row }" slot="ss">
                    <strong>{{ ((row.ss * 100) / (row.ssall || 1)).toFixed(2) }}%({{ row.ss }}/{{ row.ssall }})</strong>
                  </template>
                  <template slot-scope="{ row }" slot="exw">
                    <strong>{{ ((row.zk * 100) / (row.zkall || 1)).toFixed(2) }}%({{ row.zk }}/{{ row.zkall }})</strong>
                  </template>
                  <template slot-scope="{ row }" slot="bk">
                    <strong>{{ ((row.bk * 100) / (row.bkall || 1)).toFixed(2) }}%({{ row.bk }}/{{ row.bkall }})</strong>
                  </template>
                </Table>
              </div>

              <div v-if="type === 6 && roles === 'ROLE_PROVINCE'" class="table-wrap-self"
                   loading="true">
                <TableV2
                    id="table8"
                    show-summary
                    class="wh-100"
                    :loading="loading"
                    border
                    :summary-method="handleSum8"
                    :columns="columns5"
                    :data="bysJyqxPostDataStatistics"
                    ref="table8"
                    :max-height="rheight.value-55"
                >
                  <template slot-scope="{ row }" slot="allTotalNumber">
                    <div class="table-wrap-item">
                      {{ countSum(headCount(row), row.policyPostNoDone) }}
                    </div>
                  </template>
                  <template slot-scope="{ row }" slot="totalNumber">
                    <div class="table-wrap-item">
                      {{ headCount(row) }}
                    </div>
                  </template>
                  <template slot-scope="{ row }" slot="marketablePositionTotal">
                    <div class="table-wrap-item">
                      {{ subtotalMarket(row) }}
                    </div>
                  </template>
                  <template slot-scope="{ row }" slot="policyPostTotal">
                    <div class="table-wrap-item">
                      {{ subtotalPolicy(row) }}
                    </div>
                  </template>
                </TableV2>
              </div>
              <div v-if="type === 6 &&  roles === 'ROLE_SCHOOL'" class="table-wrap-self"
                   loading="true">
                <TableV2
                    id="table9"
                    class="wh-100"
                    show-summary
                    :loading="loading"
                    border
                    :columns="columns6"
                    :summary-method="handleSum9"
                    :data="bysJyqxPostDataStatistics"
                    ref="table9"
                    :max-height="rheight.value-55"
                >
                  <template slot-scope="{ row }" slot="majorName">
                    <div v-if=" row.zy!=='小计' ">
                      {{ '(' + row.zyCode + ')' + row.zy }}
                    </div>
                    <div v-else>
                      小计
                    </div>
                  </template>
                  <template slot-scope="{ row }" slot="allTotalNumber">
                    <div class="table-wrap-item">
                      {{ countSum(headCount(row), row.policyPostNoDone) }}
                    </div>
                  </template>
                  <template slot-scope="{ row }" slot="totalNumber">
                    <div class="table-wrap-item">
                      {{ headCount(row) }}
                    </div>
                  </template>
                  <template slot-scope="{ row }" slot="marketablePositionTotal">
                    <div class="table-wrap-item">
                      {{ subtotalMarket(row) }}
                    </div>
                  </template>
                  <template slot-scope="{ row }" slot="policyPostTotal">
                    <div class="table-wrap-item">
                      {{ subtotalPolicy(row) }}
                    </div>
                  </template>
                </TableV2>
              </div>
              <div v-if="type === 6 && roles === 'ROLE_COLLEGE'" class="table-wrap-self"
                   loading="true">
                <TableV2
                    id="table10"
                    class="wh-100"
                    show-summary
                    :loading="loading"
                    border
                    :columns="columns7"
                    :summary-method="handleSum8"
                    :data="bysJyqxPostDataStatistics"
                    ref="table10"
                    :max-height="rheight.value-55"
                >
                  <template slot-scope="{ row }" slot="majorName">
                    <div>
                      {{ '(' + row.zyCode + ')' + row.zy }}
                    </div>
                  </template>
                  <template slot-scope="{ row }" slot="allTotalNumber">
                    <div class="table-wrap-item">
                      {{ countSum(headCount(row), row.policyPostNoDone) }}
                    </div>
                  </template>
                  <template slot-scope="{ row }" slot="totalNumber">
                    <div class="table-wrap-item">
                      {{ headCount(row) }}
                    </div>
                  </template>
                  <template slot-scope="{ row }" slot="marketablePositionTotal">
                    <div class="table-wrap-item">
                      {{ subtotalMarket(row) }}
                    </div>
                  </template>
                  <template slot-scope="{ row }" slot="policyPostTotal">
                    <div class="table-wrap-item">
                      {{ subtotalPolicy(row) }}
                    </div>
                  </template>
                </TableV2>
              </div>
              <!-- 灵活就业率 -->
              <!--                             :span-method="handleSpan"-->
              <div v-show="type === 9" class="table-wrap-self" loading="true">
                <TableV2
                    id="table11"
                    class="wh-100"
                    show-summary
                    :loading="loading"
                    border
                    :columns="columns10"
                    :summary-method="handleSum10"
                    :data="flexibleEmploymentRateList"

                    ref="table11"
                    :max-height="rheight.value-55"
                >
                  <template slot-scope="{ row, index }" slot="flexiblePer">
                    <div v-if="row.flexiblePer" class="table-wrap-item">
                      {{
                        Number(row.flexiblePer) === 0 ? '0.00%' : Math.round((Number(row.flexiblePer)) * 100000) / 1000 + '%'
                      }}
                    </div>
                  </template>

                  <template slot-scope="{ row, index }" slot="selfEmployedPer">
                    <div v-if="row.selfEmployedPer" class="table-wrap-item">
                      {{
                        Number(row.selfEmployedPer) === 0 ? '0.00%' : Math.round((Number(row.selfEmployedPer)) * 100000) / 1000 + '%'
                      }}
                    </div>
                  </template>

                  <template slot-scope="{ row, index }" slot="freelancingPer">
                    <div v-if="row.freelancingPer" class="table-wrap-item">
                      {{
                        Number(row.freelancingPer) === 0 ? '0.00%' : Math.round((Number(row.freelancingPer)) * 100000) / 1000 + '%'
                      }}
                    </div>
                  </template>

                  <template slot-scope="{ row, index }" slot="eCommercePer">
                    <div v-if="row.eCommercePer" class="table-wrap-item">
                      {{
                        Number(row.eCommercePer) === 0 ? '0.00%' : Math.round((Number(row.eCommercePer)) * 100000) / 1000 + '%'
                      }}
                    </div>
                  </template>

                  <template slot-scope="{ row, index }" slot="selfEntrepreneurshipPer">
                    <div v-if="row.selfEntrepreneurshipPer">
                      {{
                        Number(row.selfEntrepreneurshipPer) === 0 ? '0.00%' : Math.round((Number(row.selfEntrepreneurshipPer)) * 100000) / 1000 + '%'
                      }}
                    </div>
                  </template>
                </TableV2>
              </div>
              <!-- 灵活就业率 学历层次-->
              <div v-show="type === 10" class="table-wrap-self" loading="true">
                <table id="table12" style="width: 100%;" v-loading="loading">
                  <thead style="background-color: #f8f8f9">
                  <tr>
                    <th class="table-wrap-item" scope="row" rowspan="2" colspan="3">学历层次</th>
                    <th class="table-wrap-item" scope="row" colspan="2">灵活就业率</th>
                    <th class="table-wrap-item" scope="row" colspan="2">个体工商户就业</th>
                    <th class="table-wrap-item" scope="row" colspan="2">自由职业</th>
                    <th class="table-wrap-item" scope="row" colspan="2">电子商务创业</th>
                    <th class="table-wrap-item" scope="row" colspan="2">个体工商户创业</th>
                  </tr>
                  <tr>
                    <th class="table-wrap-item" scope="row">落实人数</th>
                    <th class="table-wrap-item" scope="row">占比</th>
                    <th class="table-wrap-item" scope="row">落实人数</th>
                    <th class="table-wrap-item" scope="row">占比</th>
                    <th class="table-wrap-item" scope="row">落实人数</th>
                    <th class="table-wrap-item" scope="row">占比</th>
                    <th class="table-wrap-item" scope="row">落实人数</th>
                    <th class="table-wrap-item" scope="row">占比</th>
                    <th class="table-wrap-item" scope="row">落实人数</th>
                    <th class="table-wrap-item" scope="row">占比</th>
                  </tr>
                  <tr>
                    <th class="table-wrap-item" colspan="3">总计</th>
                    <th class="table-wrap-item">{{ flexibleEmploymentRateTotal.flexible }}</th>
                    <th class="table-wrap-item">{{ flexibleEmploymentRateTotal.flexiblePer }}</th>
                    <th class="table-wrap-item">{{ flexibleEmploymentRateTotal.selfEmployed }}</th>
                    <th class="table-wrap-item">{{ flexibleEmploymentRateTotal.selfEmployedPer }}</th>
                    <th class="table-wrap-item">{{ flexibleEmploymentRateTotal.freelancing }}</th>
                    <th class="table-wrap-item">{{ flexibleEmploymentRateTotal.freelancingPer }}</th>
                    <th class="table-wrap-item">{{ flexibleEmploymentRateTotal.eCommerce }}</th>
                    <th class="table-wrap-item">{{ flexibleEmploymentRateTotal.eCommercePer }}</th>
                    <th class="table-wrap-item">{{ flexibleEmploymentRateTotal.selfEntrepreneurship }}</th>
                    <th class="table-wrap-item">{{ flexibleEmploymentRateTotal.selfEntrepreneurshipPer }}</th>
                  </tr>
                  </thead>
                  <tbody>
                  <tr v-for="(item, index) in flexibleEmploymentRateList" :key="index">
                    <td class="table-wrap-item" v-if="item.topName" :rowspan="item.topRowspan"
                        :colspan="item.topColspan">{{ item.topName }}
                    </td>
                    <td class="table-wrap-item" v-if="item.middName" :rowspan="item.midRowspan"
                        :colspan="item.midColspan">{{ item.middName }}
                    </td>
                    <td class="table-wrap-item">{{ item.flexible === null || item.flexible === undefined ? '0' : item.flexible }}</td>
                    <td class="table-wrap-item">{{ item.flexiblePer === null || item.flexiblePer === undefined ? '0.00%' : item.flexiblePer }}</td>
                    <td class="table-wrap-item">{{ item.selfEmployed === null || item.selfEmployed === undefined ? '0' : item.selfEmployed }}</td>
                    <td class="table-wrap-item">{{ item.selfEmployedPer === null || item.selfEmployedPer === undefined ? '0.00%' : item.selfEmployedPer }}</td>
                    <td class="table-wrap-item">{{ item.freelancing === null || item.freelancing === undefined ? '0' : item.freelancing }}</td>
                    <td class="table-wrap-item">{{ item.freelancingPer === null || item.freelancingPer === undefined ? '0.00%' : item.freelancingPer }}</td>
                    <td class="table-wrap-item">{{ item.eCommerce === null || item.eCommerce === undefined ? '0' : item.eCommerce }}</td>
                    <td class="table-wrap-item">{{ item.eCommercePer === null || item.eCommercePer === undefined ? '0.00%' : item.eCommercePer }}</td>
                    <td class="table-wrap-item">{{ item.selfEntrepreneurship === null || item.selfEntrepreneurship === undefined ? '0' : item.selfEntrepreneurship }}</td>
                    <td class="table-wrap-item">{{ item.selfEntrepreneurshipPer === null || item.selfEntrepreneurshipPer === undefined ? '0.00%' : item.selfEntrepreneurshipPer }}</td>
                  </tr>
                  </tbody>
                </table>
              </div>
            </div>
            <!--                      <Row type="flex" justify="end" class="page">-->
            <!--                          <Page-->
            <!--                                  :current="searchForm.pageNumber"-->
            <!--                                  :total="total"-->
            <!--                                  :page-size="searchForm.pageSize"-->
            <!--                                  @on-change="changePage"-->
            <!--                                  @on-page-size-change="changePageSize"-->
            <!--                                  :page-size-opts="[10, 20, 50, 100, 200]"-->
            <!--                                  size="small"-->
            <!--                                  show-total-->
            <!--                                  show-elevator-->
            <!--                                  show-sizer-->
            <!--                          ></Page>-->
            <!--                      </Row>-->
          </Card>
        </Col>
      </Row>
    </div>
  </div>
</template>

<script>
import {getBysJyqxPostDataStatistics, getBysJyqxPostDataStatisticsOutPut} from '@/api/bys/jyqx/jyqx';
import {
  accessToAllNonProvincialSchoolsApi,
  geteMploymentRate,
  geteMploymentRateOutPut,
  getGxList,
  getxyCodeList,
  getSevenRateTimeList,
  getSevenRateProvince,
  getSevenRateSchool,
  getSevenRateCollege,
  getSevenRateEduction,
  getEmploymentRatesApi,
  getSchoolEmploymentRatesApi,
  getCollegeEmploymentRatesApi,
  getFlexibleEmploymentRateEduction,
  getFlexibleEmploymentRateX,
  getFlexibleEmploymentRateY,
  getFlexibleEmploymentRateS
} from '@/api/bys/gxjyl/jyqx';
import checkPassword from '@/views/my-components/xboot/check-password.vue';
import addEdit from '@/views/bys/personInfo/addEditBys.vue';
import {getDeptCode} from '@/api/hardshipSupport';
import {getByXlAndLevel} from '@/api/bys/code';
import {getDictDataByType} from '@/api';
import TableV2 from '@/views/xboot-components/table/table-v2.vue';
import {removeStore, setStore} from '@/libs/storage';
import {
  columns1,
  col_seven_rate_province,
  columns3,
  columnsls,
  columnsls1,
  columnsls3,
  columnsls4,
  columnsls5,
  col_seven_rate_school,
  col_seven_rate_college,
  col_seven_rate_education, columns4, columns5, columns7, columns6, columns2, columns9, columns8
} from '@/views/bys/gxjyl/column';

import XLSX from 'xlsx';
import {saveAs} from 'file-saver';
import moment from 'moment';
import cloneDeep from 'lodash/cloneDeep'
export default {
  name: 'gxjyl',
  components: {addEdit, checkPassword, TableV2},
  data() {
    return {
      boxHeight: 0, // 用于保存盒子的高度
      rheight: {value: 550},
      // 当前角色的名称
      roles: '',
      // 用于七个率的下拉框时间
      selectTimeList: [],
      type: 0,
      selectList: [],
      height1: 0,
      chow_card: false,
      loading: true,
      loading1: false,
      loading2: false,
      // 各高校落实率
      columns: [],
      columns_1: columns1,
      columns1: [],
      columns1_2: columns1,
      columns2: [],
      columns2_3: columns2,
      columns3: [],
      columns3_4: columns3,
      columns4: [],
      columns4_5: columns4,
      columns5: [],
      columns5_6: columns5,
      columns6: [],
      columns6_7: columns6,
      columns7: [],
      columns7_8: columns7,
      columns10: [],
      columns10_9: columns8,
      columns8: [],
      columns8_10: columns8,
      columns9: [],
      columns9_11: columns9,
      columnsls: [],
      columnsls_12: columnsls,
      columnsls1: [],
      columnsls1_13: columnsls1,
      columnsls3: [],
      columnsls3_14: columnsls3,
      // 高职扩招生
      columnsls4: [],
      columnsls4_15: columnsls4,
      columnsls5: [],
      columnsls5_16: columnsls5,
      xyList: [],
      bysJyqxPostDataStatistics: [],
      flexibleEmploymentRateList: [],
      flexibleEmploymentRateTotal: {
        flexible: 0,
        flexiblePer: "0.00%",
        selfEmployed: 0,
        selfEmployedPer: "0.00%",
        freelancing: 0,
        freelancingPer: "0.00%",
        eCommerce: 0,
        eCommercePer: "0.00%",
        selfEntrepreneurship: 0,
        selfEntrepreneurshipPer: "0.00%",
        total: 0
      },
      tableData: [],
      tableColumns: [],
      data: [],
      searchForm: {
        time: '2024-03-06',
        pageNumber: 1,
        pageSize: 50,
        sort: 'createTime',
        order: 'desc',
        startDate: '',
        endDate: '',
        gx: '0',
        status: '0',
        yx: '',
        zyCode: '',
        xlcc: '',
        zyCode1: '',
        jb: new Date().getFullYear(),
        by: new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDay())
      },
      total: 0,
      gxList: [],
      xlccList: [],
      realizedTotal: {
        alnumber: 0,
        alnumberUn: 0,
        alnumberpn: 0,
        bknumber: 0,
        bknumberUn: 0,
        bknumberpn: 0,
        bsnumber: 0,
        bsnumberUn: 0,
        bsnumberpn: 0,
        yjsnumber: 0,
        yjsnumberUn: 0,
        yjsnumberpn: 0,
        yjnumber: 0,
        yjnumberUn: 0,
        yjnumberpn: 0,
        zknumber: 0,
        zknumberUn: 0,
        zknumberpn: 0
      },
      postTotal: {
        allTotalNumber: 0,
        totalNumber: 0,
        marketablePositionTotal: 0,
        marketablePositionPrivate: 0,
        marketablePositionFreelance: 0,
        marketablePositionForeign: 0,
        marketablePositionIndependent: 0,
        policyPostTotal: 0,
        policyPostStudyInChina: 0,
        policyPostInGraduate: 0,
        policyPostInSecond: 0,
        policyPostInJuniorToGeneral: 0,
        policyPostGovernment: 0,
        policyPostPublic: 0,
        policyPostStateOwned: 0,
        policyPostConscription: 0,
        policyPostResearchAssistant: 0,
        policyPostUrban: 0,
        policyPostNational: 0,
        policyPostLocal: 0,
        policyPostOut: 0,
        policyPostNoDone: 0,
      },
      lastCollegeName: '',
      isFirst: true,
      createResizeObserverTime: null
    };
  },
  methods: {
    createResizeObserver() {
      const _this = this;
      clearTimeout(_this.createResizeObserverTime);
      try{
          _this.resizeObserver = new ResizeObserver(entries => {
            for (let entry of entries) {
              _this.loading = true;
              _this.createResizeObserverTime = setTimeout(() => {
                _this.boxHeight = entry.contentRect.height;
                _this.handleSearch();
              } , 650);
            }
          });
        // 观察目标元素
        _this.resizeObserver.observe(_this.$refs.monitorHigh);
      }catch(e){
        console.log(e,'e');
      };
    },
    onRestWindow() {
      let t1 = cloneDeep(this.columns_1)
      this.restTreeTableCellWidth(t1)
      this.columns = t1

      let t2 = cloneDeep(this.columns1_2)
      this.restTreeTableCellWidth(t2)
      this.columns1 = t2

      let t3 = cloneDeep(this.columns2_3)
      this.restTreeTableCellWidth(t3)
      this.columns2 = t3


      let t4 = cloneDeep(this.columns3_4)
      this.restTableCellWidth(t4)
      this.columns3 = t4

      let t5 = cloneDeep(this.columns4_5)
      this.restTreeTableCellWidth(t5)
      this.columns4 = t5 

      let t6 = cloneDeep(this.columns5_6)
      this.restTreeTableCellWidth(t6)
      this.columns5 = t6

      let t7 = cloneDeep(this.columns6_7)
      this.restTreeTableCellWidth(t7)
      this.columns6 = t7

      let t8 = cloneDeep(this.columns7_8)
      this.restTreeTableCellWidth(t8)
      this.columns7 = t8

      let t9 = cloneDeep(this.columns10_9)
      this.restTreeTableCellWidth(t9)
      this.columns10 = t9 

      let t10 = cloneDeep(this.columns8_10)
      this.restTreeTableCellWidth(t10)
      this.columns8 =  t10

      let t11 = this.columns9_11
      this.restTreeTableCellWidth(t11)
      this.columns9 = t11

      let t12 = cloneDeep(this.columnsls)
      this.restTreeTableCellWidth(t12)
      this.columnsls = t12

      let t13 = cloneDeep(this.columnsls1_13)
      this.restTreeTableCellWidth(t13)
      this.columnsls1 = t13

      let t14 = cloneDeep(this.columnsls3_14)
      this.columnsls3 = this.restTreeTableCellWidth(t14)
      this.columnsls3 = t14

      let t15 = cloneDeep(this.columnsls4_15)
      this.restTreeTableCellWidth(t15)
      this.columnsls4 = t15

      let t16 = cloneDeep(this.columnsls5_16)
      this.restTreeTableCellWidth(t16)
      this.columnsls5 = t16

      this.rheight.value = this.searchLabelWidth(this.rheight.value)
    },

    // 用于当选中七个率的时候 时间下拉框的变化
    handleSelectChange(e) {
      if (e === '1' || e === '9' || e === '0') {
        getSevenRateTimeList().then(res => {
          // 判断是否包含今天 不包含就插入今天
          this.selectTimeList = res.result;
          let currentTime = moment().format('YYYY-MM-DD');
          let currentIdx = this.selectTimeList.indexOf(currentTime);
          if (currentIdx !== -1) {
        // 如果包含，移除当前日期
        this.selectTimeList.splice(currentIdx, 1);
        }
        // 将当前日期添加到列表的最后
        this.selectTimeList.push(currentTime);
  
          this.$nextTick(function () {
            this.searchForm.time = this.selectTimeList[this.selectTimeList.length - 1];
          });
        });
      }
      this.handleSearch()
    },
    init() {
      this.handleSearch();
      // this.getDataList();
      this.getDictData();
    },
    changeTab(v) {
      this.searchForm.xlcc = v;
      this.handleSearch();
    },
    handleSum({columns, data}) {
      const sums = {};
      let byrs = 0;
      let lsrs = 0;
      let yjsbyes = 0
      let yjslsrs = 0
      if (this.roles === 'ROLE_PROVINCE' || this.roles === 'ROLE_COLLEGE') {
        columns.forEach((column, index) => {
          const key = column.key;
          if (index === 0) {
            sums[key] = {
              key,
              value: '合计'
            };
            return;
          }
          const values = data.map(item => Number(item[key]));
          if (!values.every(value => isNaN(value))) {
            const v = values.reduce((prev, curr) => {
              const value = Number(curr);
              if (!isNaN(value)) {
                return prev + curr;
              } else {
                return prev;
              }
            }, 0);
            if (column.title === "毕业人数") {
              byrs = Number(v)
              sums[key] = {
                key,
                value: v
              };
            } else if (column.title === "落实人数") {
              lsrs = Number(v)
              sums[key] = {
                key,
                value: v
              };
            } else if (column.title === "落实率") {
              sums[key] = {
                key,
                value: byrs === 0 ? '0%' : Math.round((lsrs / byrs) * 10000) / 100 + '%'
              };
            }
            if (column.key === "masterGraduate" || column.key === "doctorGraduate") {
              yjsbyes = Number(v) + yjsbyes
            }
            if (column.key === "masterImplement" || column.key === "doctorImplement") {
              yjslsrs = Number(v) + yjslsrs
            }
          } else {
            sums[key] = {
              key,
              value: ''
            };
          }
        });
        sums['byrs_yjs'] = {
          key: 'byrs_yjs',
          value: yjsbyes
        };
        sums['jyrs_yjs'] = {
          key: 'jyrs_yjs',
          value: yjslsrs
        };
        sums['jyl_yjs'] = {
          key: 'jyl_yjs',
          value: yjsbyes === 0 ? '0%' : Math.round((yjslsrs / yjsbyes) * 10000) / 100 + '%'
        };
      } else if (this.roles === 'ROLE_SCHOOL') {
        columns.forEach((column, index) => {
          const key = column.key;
          if (index === 0) {
            sums[key] = {
              key,
              value: ''
            };
            return;
          }
          if (index === 1) {
            sums[key] = {
              key,
              value: '合计'
            };
            return;
          }

          let rows = data.filter(item => item.profession === "小计")
          const values = rows.map(item => Number(item[key]));
          if (!values.every(value => isNaN(value))) {
            const v = values.reduce((prev, curr) => {
              const value = Number(curr);
              if (!isNaN(value)) {
                return prev + curr;
              } else {
                return prev;
              }
            }, 0);
            if (column.title === "毕业人数") {
              byrs = Number(v)
              sums[key] = {
                key,
                value: v
              };
            } else if (column.title === "落实人数") {
              lsrs = Number(v)
              sums[key] = {
                key,
                value: v
              };
            } else if (column.title === "落实率") {
              sums[key] = {
                key,
                value: byrs === 0 ? '0%' : Math.round((lsrs / byrs) * 10000) / 100 + '%'
              };
            }
            if (column.key === "masterGraduate" || column.key === "doctorGraduate") {
              yjsbyes = Number(v) + yjsbyes
            }
            if (column.key === "masterImplement" || column.key === "doctorImplement") {
              yjslsrs = Number(v) + yjslsrs
            }
          } else {
            sums[key] = {
              key,
              value: ''
            };
          }
        });
        sums['byrs_yjs'] = {
          key: 'byrs_yjs',
          value: yjsbyes
        };
        sums['jyrs_yjs'] = {
          key: 'jyrs_yjs',
          value: yjslsrs
        };
        sums['jyl_yjs'] = {
          key: 'jyl_yjs',
          value: yjsbyes === 0 ? '0%' : Math.round((yjslsrs / yjsbyes) * 10000) / 100 + '%'
        };
      }
      return sums;
    },
    handleSum2({columns, data}) {
      const sums = {};
      console.log("data", data)
      let total = 0;
      if (this.roles === 'ROLE_SCHOOL') {
        const rows = data.filter(item => item.profession !== "小计")
        for (const sum of rows) {
          total += Number(sum.total);
        }
      } else {
        for (const sum of data) {
          total += Number(sum.total);
        }
      }
      let lsrs = 0
      if (this.roles === 'ROLE_PROVINCE') {
        columns.forEach((column, index) => {
          const key = column.key;
          if (index === 0) {
            sums[key] = {
              key,
              value: '总计'
            };
            return;
          }
          const values = data.map(item => Number(item[key]));
          if (!values.every(value => isNaN(value))) {
            const v = values.reduce((prev, curr) => {
              const value = Number(curr);
              if (!isNaN(value)) {
                return prev + curr;
              } else {
                return prev;
              }
            }, 0);
            if (column.title === "落实人数") {
              lsrs = v
              console.log("lsrs", lsrs)
            }
            if (column.title === "占比") {
              sums[key] = {
                key,
                value: (Math.round((lsrs / total) * 10000) / 100).toFixed(2) + '%'
              };
            } else {
              sums[key] = {
                key,
                value: v
              };
            }

          } else {
            sums[key] = {
              key,
              value: ''
            };
          }

        });
        console.log("total1111111111111111111111111111", total)

      } else if (this.roles === 'ROLE_SCHOOL') {
        columns.forEach((column, index) => {
          const key = column.key;
          if (index === 0) {
            sums[key] = {
              key,
              value: ''
            };
            return;
          }
          if (index === 1) {
            sums[key] = {
              key,
              value: '总计'
            };
            return;
          }
          const rows = data.filter(item => item.profession !== "小计")
          const values = rows.map(item => Number(item[key])
          );
          if (!values.every(value => isNaN(value))) {
            const v = values.reduce((prev, curr) => {
              const value = Number(curr);
              if (!isNaN(value)) {
                return prev + curr;
              } else {
                return prev;
              }
            }, 0);
            if (column.title === "落实人数") {
              lsrs = v
              console.log("lsrs", lsrs)
            }
            if (column.title === "占比") {
              sums[key] = {
                key,
                value: (Math.round((lsrs / total) * 10000) / 100).toFixed(2) + '%'
              };
            } else {
              sums[key] = {
                key,
                value: v
              };
            }

          } else {
            sums[key] = {
              key,
              value: ''
            };
          }
        });
      } else if (this.roles === 'ROLE_COLLEGE') {
        columns.forEach((column, index) => {
          const key = column.key;
          if (index === 0) {
            sums[key] = {
              key,
              value: '总计'
            };
            return;
          }
          const values = data.map(item => Number(item[key]));
          if (!values.every(value => isNaN(value))) {
            const v = values.reduce((prev, curr) => {
              const value = Number(curr);
              if (!isNaN(value)) {
                return prev + curr;
              } else {
                return prev;
              }
            }, 0);
            if (column.title === "落实人数") {
              lsrs = v
              console.log("lsrs", lsrs)
            }
            if (column.title === "占比") {
              sums[key] = {
                key,
                value: (Math.round((lsrs / total) * 10000) / 100).toFixed(2) + '%'
              };
            } else {
              sums[key] = {
                key,
                value: v
              };
            }

          } else {
            sums[key] = {
              key,
              value: ''
            };
          }
        });
      }
      return sums;
    },
    handleSum3({columns, data}) {
      const sums = {};
      let byrs = 0;
      let lsrs = 0
      columns.forEach((column, index) => {
        const key = column.key;
        if (index === 0) {
          sums[key] = {
            key,
            value: '总计'
          };
          return;
        }
        let rows = []
        if (this.searchForm.status === '2') {
          rows = data.filter(item => item.dl_description === "小计")
        }
        if (this.searchForm.status === '3') {
          rows = data.filter(item => item.zl_description === "小计")
        }
        if (this.searchForm.status === '4') {
          rows = data.filter(item => item.xl_description === "小计")
        }
        const values = rows.map(item => Number(item[key]));
        if (!values.every(value => isNaN(value))) {
          const v = values.reduce((prev, curr) => {
            const value = Number(curr);
            if (!isNaN(value)) {
              return prev + curr;
            } else {
              return prev;
            }
          }, 0);
          if (column.title === "毕业人数") {
            byrs = v;
            console.log("byrs", byrs)
          }
          if (column.title === "落实人数") {
            lsrs = v;
            console.log("lsrs", lsrs)
          }
          if (column.title === "落实率") {
            sums[key] = {
              key,
              value: byrs === 0 ? '0%' : Math.round((lsrs / byrs) * 10000) / 100 + '%'
            };
          } else {
            sums[key] = {
              key,
              value: v
            };
          }

        } else {
          sums[key] = {
            key,
            value: ''
          };
        }
      });

      return sums;
    },
    handleSum4({columns, data}) {
      const sums = {};
      let byrs = 0;
      let lsrs = 0
      columns.forEach((column, index) => {
        const key = column.key;
        if (index === 0) {
          sums[key] = {
            key,
            value: '总计'
          };
          return;
        }
        const values = data.map(item => Number(item[key]));
        if (!values.every(value => isNaN(value))) {
          const v = values.reduce((prev, curr) => {
            const value = Number(curr);
            if (!isNaN(value)) {
              return prev + curr;
            } else {
              return prev;
            }
          }, 0);
          if (column.title === "毕业人数") {
            byrs = v;
            console.log("byrs", byrs)
          }
          if (column.title === "落实人数") {
            lsrs = v;
            console.log("lsrs", lsrs)
          }
          if (column.title === "落实率") {
            sums[key] = {
              key,
              value: byrs === 0 ? '0%' : Math.round((lsrs / byrs) * 10000) / 100 + '%'
            };
          } else {
            sums[key] = {
              key,
              value: v
            };
          }

        } else {
          sums[key] = {
            key,
            value: ''
          };
        }
      });

      return sums;
    },
    handleSum5({columns, data}) {
      const sums = {};
      let byrs = 0;
      let lsrs = 0
      console.table(columns)
      columns.forEach((column, index) => {
        const key = column.key;
        if (index === 0) {
          sums[key] = {
            key,
            value: '合计'
          };
          return;
        }
        const values = data.map(item => Number(item[key]));
        if (!values.every(value => isNaN(value))) {
          const v = values.reduce((prev, curr) => {
            const value = Number(curr);
            if (!isNaN(value)) {
              return prev + curr;
            } else {
              return prev;
            }
          }, 0);
          if (column.title === "毕业生人数") {
            byrs = v;
            console.log("byrs", byrs)
          }
          if (column.title === "去向落实人数") {
            lsrs = v;
            console.log("lsrs", lsrs)
          }
          if (column.title === "去向落实率") {
            sums[key] = {
              key,
              value: byrs === 0 ? '0%' : Math.round((lsrs / byrs) * 10000) / 100 + '%'
            };
          } else {
            sums[key] = {
              key,
              value: v
            };
          }

        } else {
          sums[key] = {
            key,
            value: ''
          };
        }
      });

      return sums;
    },
    getDataList() {
      this.loading = true;
      this.data = []
      this.tableData = []
      geteMploymentRate(this.searchForm).then(res => {
        this.loading = false;
        if (res.success) {
          if (("234101112").includes(this.searchForm.status)) {
            res.result.shift()
          }
          let data_ = res.result;
          if (Array.isArray(data_) && this.searchForm.status !== '6') {
            // 除了item.code 是 99999或者99998 都拿到
            data_ = data_.filter(item => item.code !== '99999' && item.code !== '99998');
            this.data = data_;
          }
          this.data = data_;
          this.tableData = data_;
        }
      });
    },
    getDictData() {
      // 学校
      accessToAllNonProvincialSchoolsApi().then(res => {
        if (res.success) {
          this.gxList = res.result;
          let arr = {
            code: 0,
            name: '所有学校'
          };
          this.gxList.unshift(arr);
          if (res.result.length > 0) {
            this.searchForm.gx = res.result[0].code;
          }
          console.log('所有学校', res.result);
        }
      });
      //   学历层次
      getDictDataByType('eduLevelType').then(res => {
        if (res.success) {
          this.xlccList = res.result.map(item => ({
            ...item,
            label: item.title,
            loading: false,
            children: []
          }));
          this.searchForm.xlcc = this.xlccList[0].value ? this.xlccList[0].value : '';

        }
      });
    },
    jbChange(a, b) {
      this.searchForm.jb = a;
      setStore('partTableName', a);
    },
    //导出全部数据
    dropExportAllEMploymentRateOutPut() {
      this.loading1 = true;
      if (this.searchForm.status === '0') {
        this.dropExportAll('就业落实率统计.xlsx', 'table1')
      }

      if (this.searchForm.status === '1') {
        this.dropExportAll('就业统计8个落实率.xlsx', 'table2')

      }
      if (this.searchForm.status === '2') {
        if (this.roles === 'ROLE_PROVINCE') {
          this.dropExportAll('各校专业（大类）落实率.xlsx', 'table3')

        }
        if (this.roles === 'ROLE_SCHOOL') {
          this.dropExportAll('各院系专业（大类）落实率.xlsx', 'table3')

        }
      }
      if (this.searchForm.status === '3') {
        if (this.roles === 'ROLE_PROVINCE') {
          this.dropExportAll('各校专业（中类）落实率.xlsx', 'table3')

        }
        if (this.roles === 'ROLE_SCHOOL') {
          this.dropExportAll('各院系专业（中类）落实率.xlsx', 'table3')
        }
      }
      if (this.searchForm.status === '4') {
        if (this.roles === 'ROLE_PROVINCE') {
          this.dropExportAll('各校专业（小类）落实率.xlsx', 'table3')
        }
        if (this.roles === 'ROLE_SCHOOL') {
          this.dropExportAll('各院系专业（小类）落实率.xlsx', 'table3')
        }
      }
      if (this.searchForm.status === '5') {
        this.dropExportAll('总体岗位数据统计.xlsx', 'table5')
      }
      // 高职扩招生统计
      if (this.searchForm.status === '6') {
        this.dropExportAll('高职扩招生数据统计.xlsx', 'table6')
      }

      // if (this.searchForm.status === '7') {
      //     this.dropExportAll('5所布点高校数据统计.xlsx','table7')
      // }

      if (this.searchForm.status === '8') {
        if (this.roles === 'ROLE_PROVINCE') {
          this.dropExportAll('各高校岗位数据统计.xlsx', 'table8')
        }
        if (this.roles === 'ROLE_SCHOOL') {
          this.dropExportAll('各院系岗位数据统计.xlsx', 'table9')
        }
        if (this.roles === 'ROLE_COLLEGE') {
          this.dropExportAll('各专业岗位数据统计.xlsx', 'table10')
        }
      }
      // 七个率的学历层次
      if (this.searchForm.status === '9') {
        this.dropExportAll('就业统计8个落实率-学历层次.xlsx', 'table2')
      }
      if (this.searchForm.status === '10') {
        this.dropExportAll('各专业（大类）落实率.xlsx', 'table4')
      }
      if (this.searchForm.status === '11') {
        this.dropExportAll('各专业（中类）落实率.xlsx', 'table4')
      }
      if (this.searchForm.status === '12') {
        this.dropExportAll('各专业（小类）落实率.xlsx', 'table4')
      }
      if (this.searchForm.status === '13') {
        this.dropExportAll('灵活就业率.xlsx', 'table11')
      }
      if (this.searchForm.status === '14') {
        this.dropExportAll('灵活就业率-学历层次.xlsx', 'table12')
      }

      // geteMploymentRateOutPut(this.searchForm).then(res => {
      //     this.loading1 = false;
      //     // type的格式可以可以设置，可以把appcation/json设置进去，然后设置导出的类型
      //     const blob = new Blob([res], { type: 'charset=utf-8' });
      //     let url = window.URL.createObjectURL(blob);
      //
      //     const link = document.createElement('a');
      //     link.style.display = 'none';
      //     link.href = url;
      //     link.setAttribute('download', '数据统计导出.xlsx');
      //     document.body.appendChild(link);
      //     link.click();
      //     document.body.removeChild(link); // 删除节点
      //     window.URL.revokeObjectURL(url); //释放该 url
      // });
    },

    //导出全部数据
    dropExportAll(excelName, elementId) {
      // this.loading2 = true;
      // let code = null;
      // console.log(this.searchForm.gx);
      // if (this.searchForm.gx != '0') {
      //     code = this.searchForm.gx;
      // }
      // getBysJyqxPostDataStatisticsOutPut({ code: code, status: this.searchForm.status }).then(res => {
      //     this.loading2 = false;
      //     // type的格式可以可以设置，可以把appcation/json设置进去，然后设置导出的类型
      //     const blob = new Blob([res], { type: 'charset=utf-8' });
      //     let url = window.URL.createObjectURL(blob);
      //
      //     const link = document.createElement('a');
      //     link.style.display = 'none';
      //     link.href = url;
      //     link.setAttribute('download', '政策性市场化岗位数据统计导出.xlsx');
      //     document.body.appendChild(link);
      //     link.click();
      //     document.body.removeChild(link); // 删除节点
      //     window.URL.revokeObjectURL(url); //释放该 url
      // });

      // 通过table的id获取表格元素
      const table = document.getElementById(elementId);
      const ws = XLSX.utils.table_to_sheet(table, {raw: true});

      // 设置所有列为字符串格式
      const range = XLSX.utils.decode_range(ws['!ref']);
      for (let column = range.s.c; column <= range.e.c; column++) {
        for (let row = range.s.r; row <= range.e.r; row++) {
          const cellRef = XLSX.utils.encode_cell({c: column, r: row});
          if (!ws[cellRef]) continue;
          ws[cellRef].z = 's';
        }
      }

      if (this.searchForm.status !== '5' && this.searchForm.status !== '14') {
        // 确定最后一行的行号
        const lastRowNum = range.e.r;
        // 遍历最后一行的每个单元格并删除它们(最后一行为多余数据，暂无筛选结果)
        for (let colIndex = range.s.c; colIndex <= range.e.c; colIndex++) {
          const cellAddress = XLSX.utils.encode_cell({c: colIndex, r: lastRowNum});
          if (ws[cellAddress]) {
            delete ws[cellAddress]; // 删除单元格
          }
        }
      }


      const wb = XLSX.utils.book_new();
      XLSX.utils.book_append_sheet(wb, ws, 'Sheet1');
      const wbout = XLSX.write(wb, {bookType: 'xlsx', type: 'binary'});

      function s2ab(s) {
        const buf = new ArrayBuffer(s.length);
        const view = new Uint8Array(buf);
        for (let i = 0; i !== s.length; ++i) view[i] = s.charCodeAt(i) & 0xff;
        return buf;
      }

      console.log(JSON.stringify(ws, null, 2));
      saveAs(new Blob([s2ab(wbout)], {type: 'application/octet-stream'}), excelName);
      this.loading1 = false;
    },
    handleSearch() {
      // 各高校落实率和本校落实率
      if (this.searchForm.status === '0') {
        this.loading = true
        if (this.roles === 'ROLE_PROVINCE') {
          this.type = 0;
          this.columns1[0].title = '各高校落实率'
          this.columns1[0].key = 'schoolName'
          this.columns = this.columns1;
          this.data = [];
          let schoolCode = this.searchForm.gx;
          if (schoolCode == 0) {
            schoolCode = null;
          }
          getEmploymentRatesApi({
            schoolCode: schoolCode,
            time: this.searchForm.time
          }).then(res => {
            this.data = res.result || [];
            this.loading = false
            console.log("res", res)
          });

        } else if (this.roles === 'ROLE_SCHOOL') {
          this.type = 0;
          this.columns = this.columns2;
          this.data = [];
          getSchoolEmploymentRatesApi({
            time: this.searchForm.time
          }).then(res => {

            this.data = res.result || [];
            console.log("res", res)
            this.loading = false
          });
        } else if (this.roles === 'ROLE_COLLEGE') {
          this.type = 0;
          this.columns1[0].title = "各专业名称"
          this.columns1[0].key = "profession"
          this.columns = this.columns1;
          this.data = [];
          getCollegeEmploymentRatesApi({
            time: this.searchForm.time
          }).then(res => {
            this.data = res.result || [];
            this.loading = false
          });
        }
        this.chow_card = false;
        return;
      }
      // 七个率
      if (this.searchForm.status === '1') {
        this.chow_card = true;
        this.type = 7;
        this.loading = true
        if (this.roles === 'ROLE_PROVINCE') {
          this.columns = col_seven_rate_province;
          this.data = [];
          let schoolCode = this.searchForm.gx;
          if (schoolCode == 0) {
            schoolCode = null;
          }
          getSevenRateProvince({
            schoolCode: schoolCode,
            date: this.searchForm.time
          }).then(res => {
            this.data = res.result || [];
            this.loading = false
          });

        } else if (this.roles === 'ROLE_SCHOOL') {
          this.columns = col_seven_rate_school;
          this.data = [];

          getSevenRateSchool({
            time: this.searchForm.time
          }).then(res => {
            this.data = res.result || [];
            this.loading = false

          });
        } else if (this.roles === 'ROLE_COLLEGE') {
          this.columns = col_seven_rate_college;
          this.data = [];
          getSevenRateCollege({
            time: this.searchForm.time
          }).then(res => {
            this.data = res.result || [];
            this.loading = false
          });
        }
        return;
      }
      // 七个率的学历层次
      if (this.searchForm.status === '9') {
        this.chow_card = true;
        this.type = 7;
        this.loading = true
        if (this.roles === 'ROLE_PROVINCE') {
          this.columns = col_seven_rate_education;
          this.data = [];
          let schoolCode = this.searchForm.gx;
          if (schoolCode == 0) {
            schoolCode = null;
          }
          getSevenRateEduction({
            schoolCode: schoolCode,
            date: this.searchForm.time
          }).then(res => {
            this.data = res.result;
            console.log("res", res)
            this.loading = false;
          });
        }
        return;
      }

      if (this.searchForm.status === '13') {
        this.type = 9;
        this.chow_card = true;
        this.loading = true

        if (this.roles === 'ROLE_PROVINCE') {
          this.columns8[0].title = '高校名称';
          this.columns8[0].key = 'schoolName';
          this.columns10 = this.columns8
          let schoolCode = this.searchForm.gx;
          if (schoolCode == 0) {
            schoolCode = null;
          }
          getFlexibleEmploymentRateS({
            schoolCode: schoolCode,
            date: this.searchForm.time
          }).then(res => {
            this.flexibleEmploymentRateList = res.result;
            this.loading = false
          });
        } else if (this.roles === 'ROLE_SCHOOL') {
          this.columns10 = this.columns9
          getFlexibleEmploymentRateX({
            date: this.searchForm.time
          }).then(res => {
            this.flexibleEmploymentRateList = res.result;
            console.log("res", res)
            this.loading = false;
          });
        } else if (this.roles === 'ROLE_COLLEGE') {
          this.columns8[0].title = '专业名称';
          this.columns8[0].key = 'profession';
          this.columns10 = this.columns8
          getFlexibleEmploymentRateY({
            date: this.searchForm.time
          }).then(res => {
            this.flexibleEmploymentRateList = res.result;
            this.loading = false;
          });
        }
        return;
      }

      // 灵活就业率的学历层次
      if (this.searchForm.status === '14') {
        this.loading = true;
        this.type = 10;
        let schoolCode = this.searchForm.gx;
        if (schoolCode == 0) {
          schoolCode = null;
        }
        getFlexibleEmploymentRateEduction({
          schoolCode: schoolCode,
          date: this.searchForm.time
        }).then(res => {
          this.flexibleEmploymentRateList = res.result;
          this.flexibleTotal(this.flexibleEmploymentRateList)
          this.loading = false;
        });
        return;
      }
      if (this.searchForm.status === '2') {
        if (this.roles === 'ROLE_PROVINCE') {
          this.type = 1;
          this.columns3[0].title = '学校名称';
          this.columns3[1].key = 'dl_description';
        }
        if (this.roles === 'ROLE_SCHOOL') {
          this.type = 1;
          this.columns3[0].title = '院系名称';
          this.columns3[1].key = 'dl_description';
        }
      }
      if (this.searchForm.status === '3') {
        if (this.roles === 'ROLE_PROVINCE') {
          this.type = 1;
          this.columns3[0].title = '学校名称';
          this.columns3[1].key = 'zl_description';
        }
        if (this.roles === 'ROLE_SCHOOL') {
          this.type = 1;
          this.columns3[0].title = '院系名称';
          this.columns3[1].key = 'zl_description';
        }
      }
      if (this.searchForm.status === '4') {
        if (this.roles === 'ROLE_PROVINCE') {
          this.type = 1;
          this.columns3[0].title = '学校名称';
          this.columns3[1].key = 'xl_description';
        }
        if (this.roles === 'ROLE_SCHOOL') {
          this.type = 1;
          this.columns3[0].title = '院系名称';
          this.columns3[1].key = 'xl_description';
        }
      }
      if (this.searchForm.status === '10') {
        this.type = 8;
        this.columns4[0].key = 'dl_description';
      }
      if (this.searchForm.status === '11') {
        this.type = 8;
        this.columns4[0].key = 'zl_description';
      }
      if (this.searchForm.status === '12') {
        this.type = 8;
        this.columns4[0].key = 'xl_description';
      }
      if (this.searchForm.status === '5') {
        this.type = 3;
        this.columns = this.columns1;
      }
      // 高职扩招生统计
      if (this.searchForm.status === '6') {
        this.type = 4;
        this.loading = true;
      }
      if (this.searchForm.status === '7') {
        this.type = 5;
        this.loading = true;
      }
      if (this.searchForm.status === '8') {
        this.type = 6;
      }


      if (this.searchForm.status === '5' || this.searchForm.status === '8') {
        // 获取首页去向填报数据统计
        let code = null;
        console.log(this.searchForm.gx);
        debugger;
        if (this.searchForm.gx != '0') {
          code = this.searchForm.gx;
        }
        this.loading = true;
        this.bysJyqxPostDataStatistics = []
        getBysJyqxPostDataStatistics({code: code, status: this.searchForm.status}).then((res) => {
          console.log("res", res)
          this.loading = false;
          if (res.success) {
            this.bysJyqxPostDataStatistics = res.result;
            if (this.searchForm.status === '5') {
              this.calculateTotal(this.bysJyqxPostDataStatistics);
            }
          }
        })
      } else {
        this.getDataList();
      }
    },
    handleSum10({columns, data}) {
      const sums = {};
      console.log("data", data)
      let total = 0;
      if (this.roles === 'ROLE_SCHOOL') {
        const rows = data.filter(item => item.profession !== "小计")
        for (const sum of rows) {
          total += Number(sum.total);
        }
      } else {
        for (const sum of data) {
          total += Number(sum.total);
        }
      }
      let lsrs = 0
      if (this.roles === 'ROLE_PROVINCE') {
        columns.forEach((column, index) => {
          const key = column.key;
          if (index === 0) {
            sums[key] = {
              key,
              value: '总计'
            };
            return;
          }
          const values = data.map(item => Number(item[key]));
          if (!values.every(value => isNaN(value))) {
            const v = values.reduce((prev, curr) => {
              const value = Number(curr);
              if (!isNaN(value)) {
                return prev + curr;
              } else {
                return prev;
              }
            }, 0);
            if (column.title === "落实人数") {
              lsrs = v
            }
            if (column.title === "占比") {
              sums[key] = {
                key,
                value: (Math.round((lsrs / total) * 10000) / 100).toFixed(2) + '%'
              };
            } else {
              sums[key] = {
                key,
                value: v
              };
            }
          } else {
            sums[key] = {
              key,
              value: ''
            };
          }
        });

      } else if (this.roles === 'ROLE_SCHOOL') {
        columns.forEach((column, index) => {
          const key = column.key;
          if (index === 0) {
            sums[key] = {
              key,
              value: ''
            };
            return;
          }
          if (index === 1) {
            sums[key] = {
              key,
              value: '总计'
            };
            return;
          }
          const rows = data.filter(item => item.profession !== "小计")
          const values = rows.map(item => Number(item[key])
          );
          if (!values.every(value => isNaN(value))) {
            const v = values.reduce((prev, curr) => {
              const value = Number(curr);
              if (!isNaN(value)) {
                return prev + curr;
              } else {
                return prev;
              }
            }, 0);
            if (column.title === "落实人数") {
              lsrs = v
            }
            if (column.title === "占比") {
              sums[key] = {
                key,
                value: (Math.round((lsrs / total) * 10000) / 100).toFixed(2) + '%'
              };
            } else {
              sums[key] = {
                key,
                value: v
              };
            }

          } else {
            sums[key] = {
              key,
              value: ''
            };
          }
        });
      } else if (this.roles === 'ROLE_COLLEGE') {
        columns.forEach((column, index) => {
          const key = column.key;
          if (index === 0) {
            sums[key] = {
              key,
              value: '总计'
            };
            return;
          }
          const values = data.map(item => Number(item[key]));
          if (!values.every(value => isNaN(value))) {
            const v = values.reduce((prev, curr) => {
              const value = Number(curr);
              if (!isNaN(value)) {
                return prev + curr;
              } else {
                return prev;
              }
            }, 0);
            if (column.title === "落实人数") {
              lsrs = v
              console.log("lsrs", lsrs)
            }
            if (column.title === "占比") {
              sums[key] = {
                key,
                value: (Math.round((lsrs / total) * 10000) / 100).toFixed(2) + '%'
              };
            } else {
              sums[key] = {
                key,
                value: v
              };
            }

          } else {
            sums[key] = {
              key,
              value: ''
            };
          }
        });
      }
      return sums;
    },
    flexibleTotal(rows) {
      this.flexibleEmploymentRateTotal.flexible = 0;
      this.flexibleEmploymentRateTotal.flexiblePer = "0.00%";
      this.flexibleEmploymentRateTotal.selfEmployed = 0;
      this.flexibleEmploymentRateTotal.selfEmployedPer = "0.00%";
      this.flexibleEmploymentRateTotal.freelancing = 0;
      this.flexibleEmploymentRateTotal.freelancingPer = "0.00%";
      this.flexibleEmploymentRateTotal.eCommerce = 0;
      this.flexibleEmploymentRateTotal.eCommercePer = "0.00%";
      this.flexibleEmploymentRateTotal.selfEntrepreneurship = 0;
      this.flexibleEmploymentRateTotal.selfEntrepreneurshipPer = "0.00%";
      this.flexibleEmploymentRateTotal.total = 0;

      for (const row of rows) {
        console.log("每一行数据", row)
        if (row.middName !== "小计") {
          this.flexibleEmploymentRateTotal.flexible += (row.flexible ? parseInt(row.flexible, 10) : 0);
          this.flexibleEmploymentRateTotal.selfEmployed += (row.selfEmployed ? parseInt(row.selfEmployed, 10) : 0);
          this.flexibleEmploymentRateTotal.freelancing += (row.freelancing ? parseInt(row.freelancing, 10) : 0);
          this.flexibleEmploymentRateTotal.eCommerce += (row.eCommerce ? parseInt(row.eCommerce, 10) : 0);
          this.flexibleEmploymentRateTotal.selfEntrepreneurship += (row.selfEntrepreneurship ? parseInt(row.selfEntrepreneurship, 10) : 0);
          this.flexibleEmploymentRateTotal.total += (row.total ? parseInt(row.total, 10) : 0);

          // 为每一行计算百分比
          row.flexiblePer = this.calculatePercentage(row.flexible, row.total);
          row.selfEmployedPer = this.calculatePercentage(row.selfEmployed, row.total);
          row.freelancingPer = this.calculatePercentage(row.freelancing, row.total);
          row.eCommercePer = this.calculatePercentage(row.eCommerce, row.total);
          row.selfEntrepreneurshipPer = this.calculatePercentage(row.selfEntrepreneurship, row.total);
        }
        // else {
        //   console.log("小计在这里处理",row)
        //   if (null === row.flexible || row.flexible === undefined) {
        //     row.flexible =  0;
        //     row.selfEmployed = 0;
        //     row.freelancing = 0;
        //     row.eCommerce = 0;
        //     row.selfEntrepreneurship  = 0;
        //     row.total = 0;
        //     row.flexiblePer = "0.00%";
        //     row.selfEmployedPer = "0.00%";
        //     row.freelancingPer = "0.00%";
        //     row.eCommercePer = "0.00%";
        //     row.selfEntrepreneurshipPer = "0.00%";
        //     console.log("处理完成",row)
        //   }
        // }
      }
      // 计算总计百分比
      this.flexibleEmploymentRateTotal.flexiblePer = this.calculatePercentage(this.flexibleEmploymentRateTotal.flexible, this.flexibleEmploymentRateTotal.total);
      this.flexibleEmploymentRateTotal.selfEmployedPer = this.calculatePercentage(this.flexibleEmploymentRateTotal.selfEmployed, this.flexibleEmploymentRateTotal.total);
      this.flexibleEmploymentRateTotal.freelancingPer = this.calculatePercentage(this.flexibleEmploymentRateTotal.freelancing, this.flexibleEmploymentRateTotal.total);
      this.flexibleEmploymentRateTotal.eCommercePer = this.calculatePercentage(this.flexibleEmploymentRateTotal.eCommerce, this.flexibleEmploymentRateTotal.total);
      this.flexibleEmploymentRateTotal.selfEntrepreneurshipPer = this.calculatePercentage(this.flexibleEmploymentRateTotal.selfEntrepreneurship, this.flexibleEmploymentRateTotal.total);
    },
    calculatePercentage(numerator, denominator) {
      numerator = numerator ? parseInt(numerator, 10) : 0;
      denominator = denominator ? parseInt(denominator, 10) : 0;

      if (denominator === 0) {
        return "0.00%";
      }

      const percentage = Math.round((numerator / denominator) * 10000) / 100;
      return percentage.toFixed(2) + '%';
    },
    handleSum8({columns, data}) {
      const sums = {};
      this.countUpJobs(data)
      columns.forEach((column, index) => {
        const key = column.key;
        if (index === 0) {
          sums[key] = {
            key,
            value: '总计'
          };
          return;
        }
        const values = data.map(item => Number(item[key]));
        if (!values.every(value => isNaN(value))) {
          const v = values.reduce((prev, curr) => {
            const value = Number(curr);
            if (!isNaN(value)) {
              return prev + curr;
            } else {
              return prev;
            }
          }, 0);
          sums[key] = {
            key,
            value: v
          };
        } else {
          sums[key] = {
            key,
            value: 'N/A'
          };
        }
        if (key === "allTotalNumber") {
          sums[key] = {
            key,
            value: this.postTotal.allTotalNumber
          };
        }
        if (key === "totalNumber") {
          sums[key] = {
            key,
            value: this.postTotal.totalNumber
          };
        }
        if (key === "marketablePositionTotal") {
          sums[key] = {
            key,
            value: this.postTotal.marketablePositionTotal
          };
        }
        if (key === "policyPostTotal") {
          sums[key] = {
            key,
            value: this.postTotal.policyPostTotal
          };
        }

      });
      return sums;
    },
    handleSum9({columns, data}) {
      const sums = {};
      this.countUpJobs(data)
      columns.forEach((column, index) => {
        const key = column.key;
        if (index === 0) {
          sums[key] = {
            key,
            value: ''
          };
          return;
        }
        if (index === 1) {
          sums[key] = {
            key,
            value: '总计'
          };
          return;
        }
        let rows = data.filter((item) => item.zy === "小计")
        const values = rows.map(item => Number(item[key]));
        if (!values.every(value => isNaN(value))) {
          const v = values.reduce((prev, curr) => {
            const value = Number(curr);
            if (!isNaN(value)) {
              return prev + curr;
            } else {
              return prev;
            }
          }, 0);
          sums[key] = {
            key,
            value: v
          };
        } else {
          sums[key] = {
            key,
            value: 'N/A'
          };
        }
      });
      sums['allTotalNumber'] = {
        key: 'allTotalNumber',
        value: this.postTotal.allTotalNumber
      };
      sums['totalNumber'] = {
        key: 'totalNumber',
        value: this.postTotal.totalNumber
      };
      sums['marketablePositionTotal'] = {
        key: 'marketablePositionTotal',
        value: this.postTotal.marketablePositionTotal
      };
      sums['policyPostTotal'] = {
        key: 'policyPostTotal',
        value: this.postTotal.policyPostTotal
      };
      sums['policyPostNoDone'] = {
        key: 'policyPostNoDone',
        value: this.postTotal.policyPostNoDone
      };
      return sums;
    },
    countUpJobs(rows) {
      this.postTotal.allTotalNumber = 0
      this.postTotal.totalNumber = 0
      this.postTotal.marketablePositionTotal = 0
      this.postTotal.marketablePositionPrivate = 0
      this.postTotal.marketablePositionFreelance = 0
      this.postTotal.marketablePositionForeign = 0
      this.postTotal.marketablePositionIndependent = 0
      this.postTotal.policyPostTotal = 0
      this.postTotal.policyPostStudyInChina = 0
      this.postTotal.policyPostInGraduate = 0
      this.postTotal.policyPostInSecond = 0
      this.postTotal.policyPostInJuniorToGeneral = 0
      this.postTotal.policyPostGovernment = 0
      this.postTotal.policyPostPublic = 0
      this.postTotal.policyPostStateOwned = 0
      this.postTotal.policyPostConscription = 0
      this.postTotal.policyPostResearchAssistant = 0
      this.postTotal.policyPostUrban = 0
      this.postTotal.policyPostNational = 0
      this.postTotal.policyPostLocal = 0
      this.postTotal.policyPostOut = 0
      this.postTotal.policyPostNoDone = 0
      for (const row of rows) {
        if (this.roles === 'ROLE_SCHOOL') {
          if (row.zy === "小计") {
            this.postTotal.totalNumber = this.headCount(row) + this.postTotal.totalNumber;
            this.postTotal.marketablePositionTotal = this.subtotalMarket(row) + this.postTotal.marketablePositionTotal;
            this.postTotal.marketablePositionPrivate = (row.marketablePositionPrivate ? parseInt(row.marketablePositionPrivate) : 0) + this.postTotal.marketablePositionPrivate;
            this.postTotal.marketablePositionFreelance = (row.marketablePositionFreelance ? parseInt(row.marketablePositionFreelance) : 0) + this.postTotal.marketablePositionFreelance;
            this.postTotal.marketablePositionForeign = (row.marketablePositionForeign ? parseInt(row.marketablePositionForeign) : 0) + this.postTotal.marketablePositionForeign;
            this.postTotal.marketablePositionIndependent = (row.marketablePositionIndependent ? parseInt(row.marketablePositionIndependent) : 0) + this.postTotal.marketablePositionIndependent;
            this.postTotal.policyPostTotal = this.subtotalPolicy(row) + this.postTotal.policyPostTotal;
            this.postTotal.policyPostStudyInChina = (row.policyPostStudyInChina ? parseInt(row.policyPostStudyInChina) : 0) + this.postTotal.policyPostStudyInChina;
            this.postTotal.policyPostInGraduate = (row.policyPostInGraduate ? parseInt(row.policyPostInGraduate) : 0) + this.postTotal.policyPostInGraduate;
            this.postTotal.policyPostInSecond = (row.policyPostInSecond ? parseInt(row.policyPostInSecond) : 0) + this.postTotal.policyPostInSecond;
            this.postTotal.policyPostInJuniorToGeneral = (row.policyPostInJuniorToGeneral ? parseInt(row.policyPostInJuniorToGeneral) : 0) + this.postTotal.policyPostInJuniorToGeneral;
            this.postTotal.policyPostGovernment = (row.policyPostGovernment ? parseInt(row.policyPostGovernment) : 0) + this.postTotal.policyPostGovernment;
            this.postTotal.policyPostPublic = (row.policyPostPublic ? parseInt(row.policyPostPublic) : 0) + this.postTotal.policyPostPublic;
            this.postTotal.policyPostStateOwned = (row.policyPostStateOwned ? parseInt(row.policyPostStateOwned) : 0) + this.postTotal.policyPostStateOwned;
            this.postTotal.policyPostConscription = (row.policyPostConscription ? parseInt(row.policyPostConscription) : 0) + this.postTotal.policyPostConscription;
            this.postTotal.policyPostResearchAssistant = (row.policyPostResearchAssistant ? parseInt(row.policyPostResearchAssistant) : 0) + this.postTotal.policyPostResearchAssistant;
            this.postTotal.policyPostUrban = (row.policyPostUrban ? parseInt(row.policyPostUrban) : 0) + this.postTotal.policyPostUrban;
            this.postTotal.policyPostNational = (row.policyPostNational ? parseInt(row.policyPostNational) : 0) + this.postTotal.policyPostNational;
            this.postTotal.policyPostLocal = (row.policyPostLocal ? parseInt(row.policyPostLocal) : 0) + this.postTotal.policyPostLocal;
            this.postTotal.policyPostOut = (row.policyPostOut ? parseInt(row.policyPostOut) : 0) + this.postTotal.policyPostOut;
            this.postTotal.policyPostNoDone = (row.policyPostNoDone ? parseInt(row.policyPostNoDone) : 0) + this.postTotal.policyPostNoDone;
          }
        } else {
          this.postTotal.totalNumber = this.headCount(row) + this.postTotal.totalNumber;
          this.postTotal.marketablePositionTotal = this.subtotalMarket(row) + this.postTotal.marketablePositionTotal;
          this.postTotal.marketablePositionPrivate = (row.marketablePositionPrivate ? parseInt(row.marketablePositionPrivate) : 0) + this.postTotal.marketablePositionPrivate;
          this.postTotal.marketablePositionFreelance = (row.marketablePositionFreelance ? parseInt(row.marketablePositionFreelance) : 0) + this.postTotal.marketablePositionFreelance;
          this.postTotal.marketablePositionForeign = (row.marketablePositionForeign ? parseInt(row.marketablePositionForeign) : 0) + this.postTotal.marketablePositionForeign;
          this.postTotal.marketablePositionIndependent = (row.marketablePositionIndependent ? parseInt(row.marketablePositionIndependent) : 0) + this.postTotal.marketablePositionIndependent;
          this.postTotal.policyPostTotal = this.subtotalPolicy(row) + this.postTotal.policyPostTotal;
          this.postTotal.policyPostStudyInChina = (row.policyPostStudyInChina ? parseInt(row.policyPostStudyInChina) : 0) + this.postTotal.policyPostStudyInChina;
          this.postTotal.policyPostInGraduate = (row.policyPostInGraduate ? parseInt(row.policyPostInGraduate) : 0) + this.postTotal.policyPostInGraduate;
          this.postTotal.policyPostInSecond = (row.policyPostInSecond ? parseInt(row.policyPostInSecond) : 0) + this.postTotal.policyPostInSecond;
          this.postTotal.policyPostInJuniorToGeneral = (row.policyPostInJuniorToGeneral ? parseInt(row.policyPostInJuniorToGeneral) : 0) + this.postTotal.policyPostInJuniorToGeneral;
          this.postTotal.policyPostGovernment = (row.policyPostGovernment ? parseInt(row.policyPostGovernment) : 0) + this.postTotal.policyPostGovernment;
          this.postTotal.policyPostPublic = (row.policyPostPublic ? parseInt(row.policyPostPublic) : 0) + this.postTotal.policyPostPublic;
          this.postTotal.policyPostStateOwned = (row.policyPostStateOwned ? parseInt(row.policyPostStateOwned) : 0) + this.postTotal.policyPostStateOwned;
          this.postTotal.policyPostConscription = (row.policyPostConscription ? parseInt(row.policyPostConscription) : 0) + this.postTotal.policyPostConscription;
          this.postTotal.policyPostResearchAssistant = (row.policyPostResearchAssistant ? parseInt(row.policyPostResearchAssistant) : 0) + this.postTotal.policyPostResearchAssistant;
          this.postTotal.policyPostUrban = (row.policyPostUrban ? parseInt(row.policyPostUrban) : 0) + this.postTotal.policyPostUrban;
          this.postTotal.policyPostNational = (row.policyPostNational ? parseInt(row.policyPostNational) : 0) + this.postTotal.policyPostNational;
          this.postTotal.policyPostLocal = (row.policyPostLocal ? parseInt(row.policyPostLocal) : 0) + this.postTotal.policyPostLocal;
          this.postTotal.policyPostOut = (row.policyPostOut ? parseInt(row.policyPostOut) : 0) + this.postTotal.policyPostOut;
          this.postTotal.policyPostNoDone = (row.policyPostNoDone ? parseInt(row.policyPostNoDone) : 0) + this.postTotal.policyPostNoDone;
        }
      }
      this.postTotal.allTotalNumber = this.postTotal.totalNumber + this.postTotal.policyPostNoDone;

    },
    countSum(totalNumber, policyPostNoDone) {
      if (totalNumber || policyPostNoDone) {
        return parseInt(totalNumber) + parseInt(policyPostNoDone);
      } else {
        return '0';
      }
    },
    headCount(row) {
      return this.subtotalMarket(row) + this.subtotalPolicy(row) + parseInt(row.policyPostOut)
    },
    subtotalMarket(row) {
      return parseInt(row.marketablePositionPrivate) +
          parseInt(row.marketablePositionFreelance) +
          parseInt(row.marketablePositionForeign) +
          parseInt(row.marketablePositionIndependent)

    },
    subtotalPolicy(row) {
      return parseInt(row.policyPostStudyInChina) +
          parseInt(row.policyPostGovernment) +
          parseInt(row.policyPostPublic) +
          parseInt(row.policyPostStateOwned) +
          parseInt(row.policyPostConscription) +
          parseInt(row.policyPostResearchAssistant) +
          parseInt(row.policyPostUrban) +
          parseInt(row.policyPostNational) +
          parseInt(row.policyPostLocal)
    },
    calculateTotal(rows) {
      this.realizedTotal.alnumber = 0
      this.realizedTotal.alnumberUn = 0
      this.realizedTotal.alnumberpn = 0
      this.realizedTotal.bknumber = 0
      this.realizedTotal.bknumberUn = 0
      this.realizedTotal.bknumberpn = 0
      this.realizedTotal.bsnumber = 0
      this.realizedTotal.bsnumberUn = 0
      this.realizedTotal.bsnumberpn = 0
      this.realizedTotal.yjsnumber = 0
      this.realizedTotal.yjsnumberUn = 0
      this.realizedTotal.yjsnumberpn = 0
      this.realizedTotal.yjnumber = 0
      this.realizedTotal.yjnumberUn = 0
      this.realizedTotal.yjnumberpn = 0
      this.realizedTotal.zknumber = 0
      this.realizedTotal.zknumberUn = 0
      this.realizedTotal.zknumberpn = 0
      for (const row of rows) {
        if (row.topName === '出国境(境外升学)' || (row.middName && row.middName === '小计')) {
          this.realizedTotal.alnumber = (row.alnumber ? parseInt(row.alnumber) : 0) + this.realizedTotal.alnumber;
          this.realizedTotal.alnumberUn = (row.alnumberUn ? parseInt(row.alnumberUn) : 0) + this.realizedTotal.alnumberUn;
          this.realizedTotal.bknumber = (row.bknumber ? parseInt(row.bknumber) : 0) + this.realizedTotal.bknumber;
          this.realizedTotal.bknumberUn = (row.bknumberUn ? parseInt(row.bknumberUn) : 0) + this.realizedTotal.bknumberUn;
          this.realizedTotal.bsnumber = (row.bsnumber ? parseInt(row.bsnumber) : 0) + this.realizedTotal.bsnumber;
          this.realizedTotal.bsnumberUn = (row.bsnumberUn ? parseInt(row.bsnumberUn) : 0) + this.realizedTotal.bsnumberUn;
          this.realizedTotal.yjnumber = (row.yjnumber ? parseInt(row.yjnumber) : 0) + this.realizedTotal.yjnumber;
          this.realizedTotal.yjnumberUn = (row.yjnumberUn ? parseInt(row.yjnumberUn) : 0) + this.realizedTotal.yjnumberUn;
          this.realizedTotal.zknumber = (row.zknumber ? parseInt(row.zknumber) : 0) + this.realizedTotal.zknumber;
          this.realizedTotal.zknumberUn = (row.zknumberUn ? parseInt(row.zknumberUn) : 0) + this.realizedTotal.zknumberUn;
          console.log('rows', row);
        }
      }
      this.realizedTotal.yjsnumber = this.realizedTotal.yjnumber + this.realizedTotal.bsnumber;
      this.realizedTotal.yjsnumberUn = this.realizedTotal.yjnumberUn + this.realizedTotal.bsnumberUn;
      this.realizedTotal.zknumberpn = this.realizedTotal.zknumberUn === 0 ? '0.0%' : Math.round((this.realizedTotal.zknumber / this.realizedTotal.zknumberUn) * 10000) / 100 + '%';
      this.realizedTotal.bknumberpn = this.realizedTotal.bknumberUn === 0 ? '0.0%' : Math.round((this.realizedTotal.bknumber / this.realizedTotal.bknumberUn) * 10000) / 100 + '%';
      this.realizedTotal.yjsnumberpn = this.realizedTotal.yjsnumberUn === 0 ? '0.0%' : Math.round((this.realizedTotal.yjsnumber / this.realizedTotal.yjsnumberUn) * 10000) / 100 + '%';
      this.realizedTotal.yjnumberpn = this.realizedTotal.yjnumberUn === 0 ? '0.0%' : Math.round((this.realizedTotal.yjnumber / this.realizedTotal.yjnumberUn) * 10000) / 100 + '%';
      this.realizedTotal.bsnumberpn = this.realizedTotal.bsnumberUn === 0 ? '0.0%' : Math.round((this.realizedTotal.bsnumber / this.realizedTotal.bsnumberUn) * 10000) / 100 + '%';
      this.realizedTotal.alnumberpn = this.realizedTotal.alnumberUn === 0 ? '0.0%' : Math.round((this.realizedTotal.alnumber / this.realizedTotal.alnumberUn) * 10000) / 100 + '%';

      console.log('this.realizedTotal', this.realizedTotal);
    },
    calculateSum(yjnumber, bsnumber) {
      // 检查yjnumber和bsnumber是否有效，然后计算它们的和并保留三位小数
      if (yjnumber || bsnumber) {
        return parseInt(yjnumber) + parseInt(bsnumber);
      } else {
        return '0';
      }
    },

    calculateSumpn(row) {
      let yjsnumber = (row.yjnumber ? parseInt(row.yjnumber) : 0) + (row.bsnumber ? parseInt(row.bsnumber) : 0);
      let yjsnumberUn = (row.yjnumberUn ? parseInt(row.yjnumberUn) : 0) + (row.bsnumberUn ? parseInt(row.bsnumberUn) : 0);
      if (yjsnumberUn === 0) {
        return '0.0%';
      }
      return Math.round((yjsnumber / yjsnumberUn) * 10000) / 100 + '%';
    },
    zyLoadData(item, callback) {
      item.loading = true;
      getByXlAndLevel({gradLevelDict: item.value, level: '2'}).then(res => {
        item.children = res.result.map(item => ({...item, label: item.title, value: item.profCode}));
        item.loading = false;
        callback();
      });
    },
    zyFormat(labels, selectedData) {
      const index = labels.length - 1;
      const data = selectedData[index] || false;
      this.searchForm.xlcc = data.gradLevelDict;
      this.searchForm.zyCode = data.value;
      return labels;
    },
    changeSort(e) {
      this.searchForm.sort = e.key;
      this.searchForm.order = e.order;
      if (e.order == 'normal') {
        this.searchForm.order = '';
      }
      this.getDataList();
    },
    exportData() {
      this.$refs.table.exportCsv({
        filename: 'The original data'
      });
    },
    showSelect(e) {
      this.exportData = e;
      this.selectList = e;
    },
    sjclaib(v) {
      this.showRight = true;
      // 转换null为""
      for (let attr in v) {
        if (v[attr] == null) {
          v[attr] = '';
        }
      }
      let str = JSON.stringify(v);
      let data = JSON.parse(str);
      this.form = data;
      this.showType = '1';
      this.showValue = true;
      this.openSearch = true;
      this.showUser = true;
      this.$refs.addOrEdit.sexCodeList = this.sexList;
      this.$refs.addOrEdit.mzList = this.mzList;
      this.$refs.addOrEdit.zzmmList = this.zzmmList;
      this.$refs.addOrEdit.xlccList = this.xlccList;
      this.$refs.addOrEdit.xlList = this.xlList;
      this.$refs.addOrEdit.zyList = this.zyList;
      this.$refs.addOrEdit.xxxsList = this.xxxsList;
      this.$refs.addOrEdit.pyfsList = this.pyfsList;
      this.$refs.addOrEdit.xzList = this.xzList;
      this.$refs.addOrEdit.sfslbList = this.sfslbList;
      this.$refs.addOrEdit.knslbList = this.knslbList;
      this.$refs.addOrEdit.form = data;
    },
    changePage(v) {
      this.searchForm.pageNumber = v;
      this.getDataList();
      this.clearSelectAll();
    },
    changePageSize(v) {
      this.searchForm.pageSize = v;
      this.getDataList();
    },
    calculate(a, b) {
      const num = (a / b) * 100;
      const percent = num.toFixed(2) + '%';
      return percent;
    }
  },
  beforeDestroy() {
    if (this.resizeObserver) {
      this.resizeObserver.disconnect();
    }
  },
  mounted() {
    this.onRestWindow()
    this.createResizeObserver();
    window.addEventListener('resize',this.onRestWindow)
    this.roles = JSON.parse(sessionStorage.getItem('roles'))[0];
    // this.handleSelectChange('0')
    let time = new Date();
    this.searchForm.time = moment(time).format('YYYY-MM-DD');
    this.init();
    this.handleSelectChange('0')
  },
  beforeDestroy() {
    window.removeEventListener('resize',this.onRestWindow)
  },
  beforeRouteLeave(to, from, next) {
    // 判断当前路由文件是否切换
    const isRouteChanged = to.fullPath !== from.fullPath;
    if (isRouteChanged) {
      removeStore('partTableName');
    }
    next();
  }
};
</script>

<style scoped lang="less">
.table_text {
  font-size: 14px;
}

.button_output {
  margin: 10px 0px;
}

.table-wrap-self {
  width: 100%;
  height: 100%;
  overflow: scroll;
}

.table-wrap-item {
  text-align: center;
  align-items: center;
  margin: auto;
  vertical-align: middle;
  font-size: 14px;
}

// 在调用页面写即可
//.ivu-table-with-summary {
//  .total-cell-td-container {
//    color: #dc2f03;
//    cursor: pointer;
//  }
//}

table {
  border-collapse: collapse;
  border: 2px solid rgb(140 140 140);
  font-family: sans-serif;
  font-size: 12px;
  letter-spacing: 1px;
}

caption {
  caption-side: bottom;
  padding: 10px;
  font-weight: bold;
}

thead,
tfoot {
  background-color: rgb(228 240 245);
}

th,
td {
  border: 1px solid rgb(160 160 160);
  padding: 8px 10px;
}

td:last-of-type {
  text-align: center;
}



.operation {
  margin-bottom: 24px;
}

.all-height {
  height: 100%;

  /deep/.ivu-card-body {
    height: 100%;
  }

  .marginForm {
    /deep/.ivu-form-item {
      margin-bottom: 0;
    }
  }
}



.class01 {
  height: calc(100% - 70px);

  /deep/.ivu-table-wrapper {
      height: 95% !important;
      max-height: 95% !important;
      @media (max-width: 1920px) {
          .ivu-table-body {
            max-height: 95% !important;
            height: 82% !important;
        }
      }
      @media (min-width: 1921px) and (max-width: 3440px) {
          .ivu-table-body {
              max-height: 95% !important;
              height:83% !important;
          }
      }

  }
}
</style>
